package cn.changein.framework.model.setting.client.mapper;

import cn.changein.framework.model.setting.client.entity.Client;
import cn.changein.framework.model.setting.client.model.params.ClientParam;
import cn.changein.framework.model.setting.client.model.result.ClientResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 客户 Mapper 接口
 * </p>
 *

 * @Date 2020-11-02
 * @Copyright: companyName
 * @Version 1.0
 * @Since JDK1.8
 */
@Mapper
@Repository
public interface ClientMapper extends BaseMapper<Client> {

    /**
     * 获取列表
     *

     * @Date 2020-11-02
     */
    List<ClientResult> customList(@Param("paramCondition") ClientParam paramCondition);

    /**
     * 获取map列表
     *

     * @Date 2020-11-02
     */
    List<Map<String, Object>> customMapList(@Param("paramCondition") ClientParam paramCondition);

    /**
     * 获取分页实体列表
     *

     * @Date 2020-11-02
     */
    Page<ClientResult> customPageList(@Param("page") Page page, @Param("paramCondition") ClientParam paramCondition);

    /**
     * 获取分页map列表
     *

     * @Date 2020-11-02
     */
    Page<Map<String, Object>> customPageMapList(@Param("page") Page page, @Param("paramCondition") ClientParam paramCondition);

    /**
     * 根据客户代码查询
     *
     * @param clientCode
     * @param id
     * @param deleteFlag
     * @return
     */
    Integer countByClientCode(@Param("clientCode") String clientCode, @Param("id") Long id, @Param("deleteFlag") Integer deleteFlag);

    /**
     * 根据外部编码查询
     *
     * @param outerCode
     * @param id
     * @param deleteFlag
     * @return
     */
    Integer countByOuterCode(@Param("outerCode") String outerCode, @Param("id") Long id, @Param("deleteFlag") Integer deleteFlag);

    /**
     * 根据ID列表查询
     *
     * @param clientIds
     * @param deleteFlag
     * @return
     */
    List<ClientResult> listClientIds(@Param("clientIds") String[] clientIds, @Param("deleteFlag") Integer deleteFlag);

    /**
     * 根据单位类型ID查询
     *
     * @param contactId
     * @return
     */
    Integer countByClientContactId(@Param("contactId") Long contactId);

    /**
     * 查询实体
     *
     * @param paramCondition
     * @return
     */
    ClientResult findBySpec(@Param("paramCondition") ClientParam paramCondition);

    List<String> getCodeList();

    List<String> getOuterCodeList();

    /**
     * 更新引用次数
     *

     * @Date 2020-10-31
     */
    void updateQuotedCount(@Param("id") Long id, @Param("quotedCount") Integer quotedCount);

}
